﻿#region using
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

using XmlGenSharp;
#endregion

namespace XmlGenSharp.Logic.Main
{
  public class SubclassCustomChangesGenerator : GeneratorBase
  {
    // Constructor

    #region SubclassCustomChangesGenerator()
    public SubclassCustomChangesGenerator()
      : this(null, "NotSpecified", "None", "None", "None")
    {
    }
    #endregion

    #region SubclassCustomChangesGenerator(string inputFileName, string defaultNamespace, string baseName, string parentClassName, string className)
    public SubclassCustomChangesGenerator(string inputFileName, string defaultNamespace, string baseName, string parentClassName, string className)
      : base(inputFileName, defaultNamespace)
    {
      BaseName = baseName;
      ParentClassName = parentClassName;
      ClassName = className;
    }
    #endregion

    // Public Properties

    #region OverwriteIfExists
    public override bool OverwriteIfExists
    {
      get
      {
        return false;
      }
    }
    #endregion

    #region BaseName
    public string BaseName
    {
      get;
      protected set;
    }
    #endregion

    #region ParentClassName
    public string ParentClassName
    {
      get;
      protected set;
    }
    #endregion

    #region ClassName
    public string ClassName
    {
      get;
      protected set;
    }
    #endregion

    // Public Methods

    #region GetFileName()
    public override string GetFileName()
    {
      return Path.GetFileNameWithoutExtension(InputFileName) + ".Subclass." + BaseName + ".cs";
    }
    #endregion

    #region Generate(IGeneratorContext cx)
    public override void Generate(IGeneratorContext cx)
    {
      cx.WL("#region using");
      cx.WL("using System;");
      cx.WL("#endregion");
      cx.WL("");
      cx.WL("namespace {0}", DefaultNamespace);
      cx.WL("{");
      cx.WL("  public partial class {0}", ParentClassName);
      cx.WL("  {");
      cx.WL("    public partial class {0}", ClassName);
      cx.WL("    {");
      cx.WL("      // Place custom additions to the class here.  Changes to");
      cx.WL("      // this file will not be overwritten by the code generator.");
      cx.WL("    }");
      cx.WL("  }");
      cx.WL("}");
    }
    #endregion
  }
}

